import request from '../utils/api'

// 获取设备列表
export const getDeviceList = (params) => {
  return request({
    url: '/device/list',
    method: 'get',
    params
  })
}

// 获取设备详情
export const getDeviceDetail = (id) => {
  return request({
    url: `/device/${id}`,
    method: 'get'
  })
}

// 添加设备
export const addDevice = (data) => {
  return request({
    url: '/device',
    method: 'post',
    data
  })
}

// 更新设备
export const updateDevice = (data) => {
  return request({
    url: `/device/${data.id}`,
    method: 'put',
    data
  })
}

// 删除设备
export const deleteDevice = (id) => {
  return request({
    url: `/device/${id}`,
    method: 'delete'
  })
}

// 批量删除设备
export const batchDeleteDevices = (ids) => {
  return request({
    url: '/device/batch',
    method: 'delete',
    params: { ids: ids.join(',') }
  })
}

// 获取设备统计信息
export const getDeviceStats = () => {
  return request({
    url: '/device/stats',
    method: 'get'
  })
}